package org.cargloss.cp.controller.modul.ourbusiness;

import org.cargloss.cp.model.OurBusiness;

import util.hibernate.DAO;

import com.opensymphony.xwork2.ActionSupport;

public class ActionCrud extends ActionSupport {
	private static final long serialVersionUID = -5933849517817526086L;
	private int id;
	private String initial;
	private String title;
	private String shortText;
	private String urlDetail;
	private String FileName;
	private int orderBy;

	public int getOrderBy() {
		return orderBy;
	}

	public void setOrderBy(int orderBy) {
		this.orderBy = orderBy;
	}

	public String insert() {
		DAO<Integer> dao = new DAO<Integer>();
		OurBusiness object = new OurBusiness();
		object.setInitial(getInitial());
		object.setTitle(getTitle());
		object.setShortText(getShortText());
		object.setUrlDetail(getUrlDetail());
		object.setFileName(getFileName());
		object.setOrderBy(getOrderBy());
		dao.insert(object);
		
		dao.close();
		return "empty";
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getInitial() {
		return initial;
	}

	public void setInitial(String initial) {
		this.initial = initial;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getShortText() {
		return shortText;
	}

	public void setShortText(String shortText) {
		this.shortText = shortText;
	}

	public String getUrlDetail() {
		return urlDetail;
	}

	public void setUrlDetail(String urlDetail) {
		this.urlDetail = urlDetail;
	}

	public String getFileName() {
		return FileName;
	}

	public void setFileName(String fileName) {
		FileName = fileName;
	}

	public String update() {
		DAO<Integer> dao = new DAO<Integer>();

		OurBusiness object = (OurBusiness) dao.find(OurBusiness.class,
				Integer.valueOf(getId()));
		object.setInitial(getInitial());
		object.setTitle(getTitle());
		object.setShortText(getShortText());
		object.setUrlDetail(getUrlDetail());
		object.setFileName(getFileName());
		object.setOrderBy(getOrderBy());
		dao.update(object);
		dao.close();
		return "empty";
	}

	public String delete() {
		DAO<Integer> dao = new DAO<Integer>();
		OurBusiness delete = (OurBusiness) dao.find(OurBusiness.class,
				Integer.valueOf(getId()));

		dao.delete(delete);
		dao.close();
		return "empty";
	}

}
